<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<link rel="stylesheet" href="${ctx}/resources/js/jquery-treegrid/0.2.0/css/jquery.treegrid.css">
<script type="text/javascript" src="${ctx}/resources/js/jquery-treegrid/0.2.0/js/jquery.treegrid.min.js" />
<script type="text/javascript">
	$(function(){
	    $("#pers_list tr:gt(0)").click(function(){
	    	   if($(this).find(":radio").attr("checked")=="checked"){
	    		     $(this).find(":radio").attr("checked",false);
		    	   }else{
		             $(this).find(":radio").attr("checked",true);
		    	   }
	    });
	});
	$(document).ready(function(){
		$(".tree").treegrid({
			treeColumn:0,
			expanderExpandedClass: 'fa fa-minus-square',
			expanderCollapsedClass: 'fa fa-plus-square'
		});
	});
</script>
<div class="bjui-pageHeader" style="background:#FFF;">
		<form id="pagerForm" data-toggle="ajaxsearch" action="${ctx}/sys/sysPermissionAction/toList" method="post">
        	<div style="margin-top: 5px;margin-bottom: 5px;">
		        <!-- 刷新按钮-->
				<button class="btn btn-orange" data-icon="refresh">刷新</button>
				<!-- 添加按钮-->
				<shiro:hasPermission name="permissionAdd">
			   	<a id="add_button" href="${ctx}/sys/sysPermissionAction/toAdd" class="btn btn-green" data-icon="plus" data-toggle="dialog" data-width="800" data-height="400" data-id="dialog-add" data-mask="true">添加</a>
			   	</shiro:hasPermission>
			   	<!-- 编辑按钮-->
			   	<shiro:hasPermission name="permissionEdit">
			   	<a href="${ctx}/sys/sysPermissionAction/toEdit?id={#bjui-selected}" class="btn btn-blue" data-icon="edit" data-toggle="dialog" data-width="800" data-height="400" data-id="dialog-edit" data-mask="true">编辑</a>
			   	</shiro:hasPermission>
			    <!-- 删除按钮-->
			   	<shiro:hasPermission name="permissionDel">
			    <a href="${ctx}/sys/sysPermissionAction/toDel?id={#bjui-selected}" class="btn btn-red" data-toggle="dialog" data-width="600" data-height="300"  data-mask="true" data-id="dialog-del" data-icon="remove">删除</a>
			   	</shiro:hasPermission>
		   	</div>
	   	</form>
	</div>

	<!-- 内容区 -->
	<div class="bjui-pageContent tableContent" id="pers_list">
	    <table class="table table-bordered table-hover table-striped table-top tree">
 	     <thead>
	    		<tr style="height:30px;">
	    			<th>状态</th>
		    		<th width="200px">权限名称</th>
		    		<th>父类名称</th>
		    		<th>排序编码</th>
		    		<th>权限路径</th>
		    		<th>权限编码</th>
		    		<th>权限类型</th>
		    		<th>启用</th>
		    		<th>权限描述</th>
	    		</tr>
	    	</thead> 
	    	<tbody>
	    	 <c:forEach items="${permissionList}" var="p">
	    	 	<tr data-id="${p.id}" class="treegrid-${p.id} treegrid-parent-${p.parentId}">
	    	 		<td><input name="pers_radio" type="radio"  /></td>
	    	 		<td>${p.name}</td>
	    			<td>${p.parentName}</td>
	    			<td>${p.seqIdx}</td>
	    			<td>${p.url}</td>
	    			<td>${p.sysId}</td>
	    			<td>
	    				<c:if test="${p.type=='F'}">
	    					<span style="color:red">菜单</span>
	    				</c:if>
	    				<c:if test="${p.type=='O'}">
							<span style="color:green">操作</span>
						</c:if>
	    			</td>
	    			<td>
	    				<c:if test="${p.isUsed=='Y'}">
	    					<span style="color:green">启用</span>
	    				</c:if>
	    			</td>
	    			<td>${p.description}</td>
	    	 	</tr>
	    	 </c:forEach>
	    <%-- 	 <c:forEach items="${permissionList}" var="level1">
	    	 	<c:if test="${empty level1.parentId}">
	    	 		<tr data-id="${level1.id}" style="font-weight: bolder;">
	    	 			<td>${level1.name}</td>
		    			<td>${level1.parentName}</td>
		    			<td>${level1.seqIdx}</td>
		    			<td>${level1.url}</td>
		    			<td>${level1.sysId}</td>
		    			<td>${level1.type}</td>
		    			<td>${level1.isUsed}</td>
		    			<td>${level1.description}</td>
	    	 		</tr>
	    	 		<c:forEach items="${permissionList}" var="level2">
	    	 			<c:if test="${level2.parentId == level1.id}">
	    	 				<tr data-id="${level2.id}" style="font-weight: bold;">
		    	 				<td>&nbsp;&nbsp;&nbsp;&nbsp;${level2.name}</td>
			    				<td>${level2.parentName}</td>
			    				<td>${level2.seqIdx}</td>
			    				<td>${level2.url}</td>
			    				<td>${level2.sysId}</td>
			    				<td>${level2.type}</td>
			    				<td>${level2.isUsed}</td>
			    				<td>${level2.description}</td>
	    	 				</tr>
	    	 				<c:forEach items="${permissionList}" var="level3">
	    	 					<c:if test="${level3.parentId == level2.id}">
	    	 					<tr data-id="${level2.id}">
			    	 				<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${level3.name}</td>
				    				<td>${level3.parentName}</td>
				    				<td>${level3.seqIdx}</td>
				    				<td>${level3.url}</td>
				    				<td>${level3.sysId}</td>
				    				<td>${level3.type}</td>
				    				<td>${level3.isUsed}</td>
				    				<td>${level3.description}</td>
	    	 					</tr>
	    	 					</c:if>
	    	 				</c:forEach>
	    	 			</c:if>
	    	 		</c:forEach> 
	    	 	</c:if>
	    	</c:forEach>  --%>
	    	</tbody> 
	    </table>
	</div>